package com.company.project.service.impl;

import com.company.project.dao.ThesisProcessMapper;
import com.company.project.model.ThesisProcess;
import com.company.project.service.ThesisProcessService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by CodeGenerator on 2018/10/09.
 */
@Service
@Transactional
public class ThesisProcessServiceImpl extends AbstractService<ThesisProcess> implements ThesisProcessService {
    @Resource
    private ThesisProcessMapper thesisProcessMapper;

    @Override
    public List selectSubmissionprocess() {
        return thesisProcessMapper.selectSubmissionprocess();
    }

    /**
     * 修改投稿流程
     * @param thesisProcess
     * @return
     */
    @Override
    public Boolean updateTP(ThesisProcess thesisProcess) {
        List list = thesisProcessMapper.selectSubmissionprocess();
        if(list.size()>0){
            Boolean aBoolean = thesisProcessMapper.updateTP(thesisProcess);
            return aBoolean;
        }else {
            int insert = thesisProcessMapper.insertTP(thesisProcess);
            if (insert>0){
                return true;
            }else {
                return false;
            }
        }
    }

    @Override
    public int insertTP(ThesisProcess thesisProcess) {
        return thesisProcessMapper.insertTP(thesisProcess);
    }

}
